from django.db import models

class Customer(models.Model):
    name = models.CharField(maxlength=50)
    country = models.CharField(maxlength=50)
    class Admin:
        list_display = ("name","country")

    def __str__(self):
        return "%s (%s)" % (self.name, self.country)
    
class Project(models.Model):
    title = models.CharField(maxlength=50)
    date = models.DateField()
    description = models.TextField()
    technologies = models.CharField(maxlength=50)
    size = models.CharField(maxlength=50)
    screenshot = models.CharField(maxlength=50, null=True, blank=True)
    customer = models.ForeignKey(Customer)
    class Admin:
        list_display = ("title", "date", "customer")
        ordering = ["-date"]
        search_fields = ("title", "description")
        list_filter = ("date",)


    def __str__(self):
        if self.screenshot:
            return "%s, %s, %s, %s" % (self.title, self.date, self.screenshot, self.customer)
        else:
            return "%s, %s, %s" % (self.title, self.date, self.customer)